package mazeBueno1;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;

import javax.swing.JPanel;

public class Test2 extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void paintComponent(Graphics g) {
		int number = 70;
		
		// fill with the color you want
		int wide = getWidth();
		int tall = getHeight();
		g.setColor(Color.white);
		g.fillRect(0, 0, wide, tall);
		
		// go into Graphics2D for all the fine art, more options
		// optional, here I just get variable Stroke sizes
		Graphics2D g2 = (Graphics2D) g;
		int w = wide / number;
		//int h = tall / number;
		g2.setColor(Color.cyan);
		
		g2.setStroke(new BasicStroke(1));
		// the verticles
		for (int i = 1; i < number; i++) {
			g2.drawLine(i * w, 0, i * w, tall);
		}
		// the horizontals
		for (int i = 1; i < number; i++) {
			//g2.drawLine(0, i * h, wide, i * h);
		}
		
		// that will have a little glitch with the integer math
		// the grid will have the bottom row slightly larger
		// to overcome that, you must use double
		
		g2.setColor(Color.red);
		double rowH = getHeight() / (double)number;
		for (int i = 1; i < number; i++) {
			Rectangle2D rect = new Rectangle2D.Double(1, 1, 3, 3);
			Line2D line = new Line2D.Double(0.0, (double) i * rowH,
			(double) getWidth(), (double) i * rowH);
			g2.draw(line);
			g2.draw(rect);
		}
	}
}
